package com.yuexun.dhdoctor.module.email.adapter;

import android.view.View;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.TextView;

import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.module.email.bean.MailDataBean;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by work-jx on 2016/8/2.
 */
public class MailListAdapter extends KJAdapter<MailDataBean> {

    //是否显示 未读标记
    private boolean isShowReadstate = false;

    public void setShowReadstate() {
        this.isShowReadstate = true;
    }

    public MailListAdapter(AbsListView view, Collection<MailDataBean> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder adapterHolder, MailDataBean mailDataBean, boolean b) {
        TextView content = adapterHolder.getView(R.id.item_maillist_content);
        adapterHolder.setText(R.id.item_maillist_name_and_position, mailDataBean.getAddresser() + "." + mailDataBean.getAddresserDP());
        adapterHolder.setText(R.id.item_maillist_title, mailDataBean.getTitle());
        adapterHolder.setText(R.id.item_maillist_time, mailDataBean.getUpdate_DT());
        ImageView dots = adapterHolder.getView(R.id.readState_dots);
//        String contents = mailDataBean.getContent().replace("＜", "<").replace("＞",">");
//        content.setText(Html.fromHtml(contents));

        if (isShowReadstate) {
            if (mailDataBean.getReadstate().equals("1")) {
                dots.setVisibility(View.VISIBLE);
            } else {
                dots.setVisibility(View.GONE);
            }
        } else {
            dots.setVisibility(View.GONE);
        }
    }
}
